window.onload=function(){
var oDiv = document.getElementById('box');
//			获取屏幕的宽度和高度
//			alert(window.screen.availHeight - oDiv.clientHeight);
	oDiv.addEventListener("touchstart",function(e){
//				div的初始位置
		old_left = oDiv.offsetLeft;
		old_top = oDiv.offsetTop;
//				起始位置
		start_x = e.changedTouches[0].clientX;
//				console.log(start_x);
		start_y = e.changedTouches[0].clientY;
//				移动
		oDiv.addEventListener("touchmove",function(e){
//					获得鼠标当前的位置
			move_x = e.changedTouches[0].clientX;
			move_y = e.changedTouches[0].clientY;
//					console.log(move_x);
//					计算新的位置
			var new_left = move_x - start_x + old_left;
			var new_top = move_y - start_y + old_top;
//					计算出left值
			if(new_left<0){
				new_left = 0;
			}
			if(new_left>document.body.clientWidth - oDiv.clientWidth){
				new_left = document.body.clientWidth - oDiv.clientWidth;
			}
			if(new_top<0){
				new_top = 0;
			}
			if(new_top>window.screen.availHeight - oDiv.clientHeight){
				new_top = window.screen.availHeight - oDiv.clientHeight;
			}
//					赋值
			oDiv.style.left = new_left + 'px';
			oDiv.style.top = new_top + 'px';
		})
	},false)	
}
	